<%@page import="main.LogicImageSegmentation"%>
<%@page import="java.io.File"%>
<%@page import="java.util.ArrayList"%>
<%@page import="main.OneDataTest"%>
<jsp:useBean id="lis" class="main.LogicImageSegmentation" scope="application"/>
<%
    ArrayList<String> value = new ArrayList<String>();
    String def = "null";

    String rcc = request.getParameter("rcc");
    if (!rcc.equalsIgnoreCase(def)) {
        value.add(rcc);
    }

    String rcr = request.getParameter("rcr");
    if (!rcr.equalsIgnoreCase(def)) {
        value.add(rcr);
    }

    String rpc = request.getParameter("rpc");
    if (!rpc.equalsIgnoreCase(def)) {
        value.add(rpc);
    }

    String sld5 = request.getParameter("sld5");
    if (!sld5.equalsIgnoreCase(def)) {
        value.add(sld5);
    }

    String sld2 = request.getParameter("sld2");
    if (!sld2.equalsIgnoreCase(def)) {
        value.add(sld2);
    }

    String vm = request.getParameter("vm");
    if (!vm.equalsIgnoreCase(def)) {
        value.add(vm);
    }

    String vsd = request.getParameter("vsd");
    if (!vsd.equalsIgnoreCase(def)) {
        value.add(vsd);
    }

    String hm1 = request.getParameter("hm1");
    if (!hm1.equalsIgnoreCase(def)) {
        value.add(hm1);
    }

    String hsd = request.getParameter("hsd");
    if (!hsd.equalsIgnoreCase(def)) {
        value.add(hsd);
    }

    String im = request.getParameter("im");
    if (!im.equalsIgnoreCase(def)) {
        value.add(im);
    }

    String rrm = request.getParameter("rrm");
    if (!rrm.equalsIgnoreCase(def)) {
        value.add(rrm);
    }

    String rbm = request.getParameter("rbm");
    if (!rbm.equalsIgnoreCase(def)) {
        value.add(rbm);
    }

    String rgm = request.getParameter("rgm");
    if (!rgm.equalsIgnoreCase(def)) {
        value.add(rgm);
    }

    String erm = request.getParameter("erm");
    if (!erm.equalsIgnoreCase(def)) {
        value.add(erm);
    }

    String ebm = request.getParameter("ebm");
    if (!ebm.equalsIgnoreCase(def)) {
        value.add(ebm);
    }

    String egm = request.getParameter("egm");
    if (!egm.equalsIgnoreCase(def)) {
        value.add(egm);
    }

    String vam = request.getParameter("vam");
    if (!vam.equalsIgnoreCase(def)) {
        value.add(vam);
    }

    String sm = request.getParameter("sm");
    if (!sm.equalsIgnoreCase(def)) {
        value.add(sm);
    }

    String hm2 = request.getParameter("hm2");
    if (!hm2.equalsIgnoreCase(def)) {
        value.add(hm2);
    }

    // get the app path
    String appPath = config.getServletContext().getRealPath("/");
    //System.out.println("APP PATH : "+appPath);
    // data set path                 
    File ff = new File(appPath);
    //String dataSetPath = ff.getParentFile().getParentFile().toString() + "/";     // get /ImageSegmentation/ ..
    String dataSetPath = appPath;   // get /ImageSegmentation/ ..

    
    int valuemodelalgorithmused = 0;
    if (request.getParameter("id") != null) {
        valuemodelalgorithmused = Integer.parseInt(request.getParameter("id"));
        System.out.println("value model "+valuemodelalgorithmused);
    }
    try {
        String [] values= new String[value.size()+1];
        for (int j =0; j<value.size();j++){
            values[j] = value.get(j);
            System.out.println("do classify "+j +" "+values[j]);
        }    
        values[value.size()] = "GRASS";
        OneDataTest odt = new OneDataTest(values);
        System.out.println("one data test");
        
        for(int j=0; j<odt.valatr.length;j++){
            System.out.println("odt "+j+" "+odt.valatr[j]);
        }
        
        
        lis.FinalClassify(dataSetPath + LogicImageSegmentation.FILE_DATA_SET_NAME_ARFF, dataSetPath + LogicImageSegmentation.FILE_DATA_TEST_ONE_NAME_ARFF, dataSetPath + LogicImageSegmentation.FILE_DATA_TEST_ONE_NAME_CSV, odt, 1);
        String result = lis.resultClassifyOneInput;
        
        out.println();
        Cookie result_cookie = new Cookie("classifyresult", result);
        result_cookie.setMaxAge(3 * 24 * 60 * 60);
        response.addCookie(result_cookie);
    } catch (Exception e) {
        out.println("false");
        e.printStackTrace();
    }

    

%>


